//
// Created by ct on 2021/9/28.
//
#include "lib/common.h"

int another_shared = 0;

void * thread_run(void *arg) {
    int *calculator = (int *) arg;
    printf("hello, world, tid == %lu \n", pthread_self());
    for (int i = 0; i < 1000; i++) {
        printf("%s ","c");
        *calculator += 1;
        another_shared += 1;
    }
    return NULL;
}

int main(int argc, char *argv[]) {

    int calculator = 0;

 //   printf("%d  \n",calculator);
    pthread_t tid1;
    pthread_t tid2;

    pthread_create(&tid1, NULL, thread_run, &calculator);
    pthread_create(&tid2, NULL, thread_run, &calculator);
    pthread_join(tid1, NULL);
    pthread_join(tid2, NULL);
    printf("calculator is %d \n", calculator);
    printf("another_shared is %d \n", another_shared);

  //  printf("%0.2f \n",75*1.5);
}